﻿using System;
using System.Web.Mvc;
using Reece.Open.Mvc.Two.Factories;
using Reece.Open.Objects;

namespace Reece.Open.Mvc.Two.Extenders
{
    public class SubMenu : IDisposable
    {
        private ViewContext _view;
        private INestedMenu _subMenu;

        public SubMenu(ViewContext viewContext, string id = null)
        {
            _view = viewContext;
            _subMenu = MenuFactory.GetMenuContainer(MenuFactory.ContainerType.SubMenu, id);
            _view.Writer.WriteLine(_subMenu.StartMenu());
        }

        public void Dispose()
        {
            _view.Writer.WriteLine(_subMenu.FinishMenu());
        }
    }
}